脚本内容如下
脚本内变量memchached port user mem根据个人需求自己修改
sh
#!/bin/sh # # memcached Startup script for memcached processes # # chkconfig: - 90 10 # description: Memcache provides fast memory based storage. # processname: memcached [ -f memcached ] || exit 0 memcached="/data/soft/memcached/bin/memcached" prog=$(basename $memcached) port=11211 user=nobody # memory use mem=64 start() { echo -n $"Starting $prog " # Starting memcached with 64MB memory on port 11211 as deamon and user nobody $memcached -m $mem -p $port -d -u $user RETVAL=$? echo return $RETVAL } stop() { if test "x`pidof memcached`" != x; then echo -n $"Stopping $prog " killall memcached echo fi RETVAL=$? return $RETVAL } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; condrestart) if test "x`pidof memcached`" != x; then stop start fi ;; *) echo $"Usage: $0 {start|stop|restart|condrestart}" exit 1 esac exit $RETVAL
将脚本保存在 /etc/init.d/目录下,如/etc/init.d/memcached
执行如下命令
sh
chmod +x /etc/init.d/memcached chkconfig memcached on service memcached start
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。